<?php
class Page {
	
	private $content = array();
	private $properties = array();

    public function __set($var, $value)
    {
        $var = strtolower($var);
		$this->properties[$var] = $value;
    }
 
    public function __get($var)
    {
        $var = strtolower($var);
		if (array_key_exists ($var, $this->properties))
		{
			return $this->properties[$var];
		}else{
       		return NULL;
		}
    }
		
	function startContent($name)
	{
		$this->content[$name] = '';
		ob_start();
	}
	
	function endContent()
	{
		$this->content[key($this->content)] = ob_get_contents();
  		ob_end_clean();
	}
	
	function contentPlaceholder($name)
	{
		return $this->content[$name];
	}
	
	function template($template)
	{
		$this->properties['template'] = $template;
	}

    function redirect($url,$permanent = false)
    {
        if($permanent)  
        {  
            header('HTTP/1.1 301 Moved Permanently');  
        }
        header('Location: '.$url);  
        exit();  
    }
    
    function isPostback()
    {
       if (isset($_POST['submitted'])){
           if ($_POST['submitted'] == '1')
           {
               return true;
           }
       }
       return false;
	}
}